using IQIGame.Onigao.GamePlay;

namespace IQIGame.Onigao.Logic
{
    /// <summary>
    /// 应用npc循环表演（同时只能有一个生效）
    /// 参数列表1:1：tag，2：LevelRoutineAct.Id
    /// </summary>
    public class ExecApplyRoutineAct : BaseServiceExecution
    {
        public override void Execute(LevelRegion region, LevelPlayer player)
        {
            var config = _config as ExecParamApplyRoutineAct;
            if (!config.tagOrMcid.TryGetValue(triggerEntity, out int tagOrMcid))
            {
                LogicLog.LogError("无法获取到tagOrMcid.");
                return;
            }
            int actId = config.actId;

            LevelEntity entity = tagOrMcid == 0 ? triggerEntity : region.GetEntityByTagOrMcid(tagOrMcid);

            if (entity == null)
            {
                LogicLog.LogError($"根据tagOrMcid[{tagOrMcid}]找不到实体。");
                return;
            }
            entity.InitRoutineAct(actId);
        }
    }
}
